
#include <map>

template <class T, class U>
class CMap
{

private :
	typedef std::map<T, U>		MAPS;
	typedef MAPS::iterator		MAPS_ITR;
	typedef std::pair<T,U>		MAPS_PAIR;

public :

	bool isEmpty() const { return m_container.empty(); }
	size_t size() const { return m_container.size(); }
	
	int add( T key, U data )
	{
		MAPS_ITR itr = m_container.find( key );
		if( m_container.end() != itr )
			return -1;
		
		m_container.insert( MAPS_PAIR(key, data) );		
		return m_container.size();
	}

	int get( T key, U& data )
	{
		MAPS_ITR itr = m_container.find( key );
		if( m_container.end() == itr )
			return -1;

		data = itr->second;

		return 0;
	}

	int del( T key )
	{
		MAPS_ITR itr = m_container.find( key );
		if( m_container.end() == itr )
			return -1;

		m_container.erase( key );		
		return m_container.size();
	}

	void resetCursor() { m_itrCurPos = m_container.begin(); }
	int nextCursor() 
	{
		if( m_itrCurPos != m_container.end() )
		{
			m_itrCurPos++;
			return 0;
		}
		else
			return -1;
		
	}

	int getCursor_key( T& key ) 
	{
		U data;
		if( 0 > get( m_itrCurPos->first, data ) )
			return -1;
		
		key = m_itrCurPos->first;
		
		return 0;
	}

	int getCursor_data( U& data ) 
	{		
		if( 0 > get( m_itrCurPos->first, data ) )
			return -1;		
		
		return 0;
	}	
	

	CMap() { };
	virtual ~CMap() {  m_container.clear(); } ;

private :

	MAPS		m_container;
	MAPS_ITR	m_itrCurPos;

};
